<template>
  <view class="page">
    <nav-bar>
        <template #title>
            编辑资料
        </template>
    </nav-bar>
    <view class="container">
        <avant-form
        ref="formRules"
        v-model="form"
        :option="options"
        @submit="submit"
      >
      </avant-form>
      <view class="sub-btn">
        <!-- <van-button type="primary" @click="proxy.$refs.formRules.reset()"
          >重置</van-button
        > -->
        <van-button type="primary" round size="large" @click="proxy.$refs.formRules.submit()"
          >提交</van-button
        >
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import formOption from "./formOption";
const { proxy } = getCurrentInstance();
const form = ref({
    name: 'Avant',
    phone: '15852323253',
    email: 'ai_config124@163.com',
    sex: '1'
});
const options = computed(() => {
  return formOption(proxy);
});

function submit() {
    console.log(form.value);
    uni.showToast({
        title: '编辑成功',
        icon: 'success'
    })
    setTimeout(() => {
        navigateBack()
    }, 1000)
}
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: calc(100% - 46px);
  .sub-btn {
    margin: 16px;
  }
}
</style>